/*
 * Copyright (C) 2018 guomw.Inc. All rights reserved.
 * 项目名称： report-manage
 * 文件名称： FileObjectConsumer.java
 * Date：18-11-5 上午10:54
 * Author: guomw
 */

package com.guomw.report.service.service.upload;

import org.apache.commons.vfs2.FileObject;
import org.apache.commons.vfs2.FileSystemException;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Objects;

/**
 * @author guomw
 * @date 2018/9/26
 */
@FunctionalInterface
public interface FileObjectConsumer {
    /**
     * Performs this operation on the given argument.
     *
     * @param t the input argument
     */
    void accept(FileObject t) throws IOException, URISyntaxException;

    /**
     * Returns a composed {@code Consumer} that performs, in sequence, this
     * operation followed by the {@code after} operation. If performing either
     * operation throws an exception, it is relayed to the caller of the
     * composed operation.  If performing this operation throws an exception,
     * the {@code after} operation will not be performed.
     *
     * @param after the operation to perform after this operation
     * @return a composed {@code Consumer} that performs in sequence this
     * operation followed by the {@code after} operation
     * @throws NullPointerException if {@code after} is null
     */
    default FileObjectConsumer andThen(FileObjectConsumer after) {
        Objects.requireNonNull(after);
        return t -> { accept(t); after.accept(t); };
    }
}
